package com.yuanlx.SpringEntityDemo;

import java.awt.event.FocusEvent;

import org.aopalliance.intercept.Interceptor;
import org.beetl.sql.core.ClasspathLoader;
import org.beetl.sql.core.ConnectionSource;
import org.beetl.sql.core.ConnectionSourceHelper;
import org.beetl.sql.core.DefaultConnectionSource;
import org.beetl.sql.core.SQLLoader;
import org.beetl.sql.core.SQLManager;
import org.beetl.sql.core.UnderlinedNameConversion;
import org.beetl.sql.core.db.DBStyle;
import org.beetl.sql.core.db.MySqlStyle;
import org.beetl.sql.ext.DebugInterceptor;
import org.beetl.sql.ext.spring4.BeetlSqlDataSource;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import com.alibaba.druid.pool.DruidDataSource;





public class App {
	public static void main(String[] args) throws Exception
	{
		DruidDataSource d = new DruidDataSource();
		DefaultConnectionSource df= new DefaultConnectionSource ();  
		BeetlSqlDataSource dataSource = new BeetlSqlDataSource();
		System.out.println("hello BeetlSqlDataSource");
		ApplicationContext context = new FileSystemXmlApplicationContext("file:E:\\eclipseworkspace\\SpringLegacyDemo\\SpringCommonDemo\\SpringEntityDemo\\src\\main\\resources\\beetlsqlgen.xml"); //new FileSystemXmlApplicationContext("");
		
		
		
//		dataSource.setMasterSource(master);
		SQLManager sqlManager = context.getBean(SQLManager.class);
		
//		          new FocusEvent(source, id); (new String[] {"Spring-Customer.xml"});
		
//		ConnectionSource source = ConnectionSourceHelper.getSingle(driver, url, userName, password);
//		DBStyle mysql = new MySqlStyle();j
//		// sql语句放在classpagth的/sql 目录下
//		SQLLoader loader = new ClasspathLoader("/sql"); //		// 数据库命名跟java命名一样，所以采用DefaultNameConversion，还有一个是UnderlinedNameConversion，下划线风格的， //		UnderlinedNameConversion nc = new  UnderlinedNameConversion(); //		// 最后，创建一个SQLManager,DebugInterceptor 不是必须的，但可以通过它查看sql执行情况
//		SQLManager sqlManager = new SQLManager(mysql,loader,source,nc,new Interceptor[]{new DebugInterceptor()});
		        //cust = (CustomerService)context.getBean("customerService");
		sqlManager.genPojoCodeToConsole("Course");
		System.out.println("hello BeetlSqlDataSource");
	}
}

